/**
 * 2
 *  
 * @Author : Ruoyu Wang
 * @DateTime : 24-9-11 下午7:49
 */

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cin >> m;
    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    int x = 0, y = 0;
    while (x < a.size() && y < b.size()) {
        if (a[x] <= b[y]) {
            cout << a[x++] << " ";
        } else {
            cout << b[y++] << " ";
        }
    }
    while (x < a.size()) {
        cout << a[x++] << " ";
    }
    while (y < b.size()) {
        cout << b[y++] << " ";
    }
    return 0;
}